export default {
	async getBankList() {
		let res= await this.httptool.post(this.apis.bankCardList, this.params);
		this.list = this.tool.trimNull(res.data, []);
//		if(this.list.length > 0) {
//				for(var i = 0; i < this.list.length; i++) {
//					this.list[i].cardNumber = this.cutBankCard(this.list[i].cardNumber);
//				}
//			}
		
	},
	cutBankCard(carnum) {
		var str = carnum.substring(carnum.length - 4);
		return("*** *** *** "+str);
	},
	async getBankdetail(id) {
		let params = {
			id: id
		};
		let res=await this.httptool.post(this.apis.getBankdetail, params);
		this.modelData = res.data;
		
	},
	async handleSave() {
		let rule = [{
				name: 'name',
				label: '持卡人姓名',
				rule: ['validateEmpty_']
			}, {
				name: 'cardNumber',
				label: '银行卡号',
				rule: ['validateNum_']
			}, {
				name: 'cardType',
				label: '开户行',
				rule: ['validateEmpty_']
			},
			{
				name: 'phone',
				label: '银行预留手机号',
				rule: ['validateTel_']
			}
		]
		if(!this.validatetool.validate(this, this.info, rule)) {
			return;
		}
		if(this.agree == true) {
			let res=await this.httptool.post(this.apis.addBankcard, this.info);
			this.$message('绑定成功!');
			this.info={
				name: '',
					cardNumber: '', //卡号
					cardTypeCN: '',
					cardType: '', //卡类型(农业或建设或招商或中国银行)(必填)
					effectiveDate: '', //有效日期(必填)
					defaultCard: null,
			};
			this.getBankList();
			
		} else {
			this.$message('您还未同意用户协议');
			return;
		}

	},
	async unbindCards() {
		let params = {
			id: this.id
		};
		let res=await this.httptool.post(this.apis.unbindBankcard, params);
		this.$message('已解除绑定!');
		this.getBankList();
		
	}

}